package vista;

import controlador.ControladorListadoMasVendido;

import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoMasVendido extends javax.swing.JFrame {
    private ControladorListadoMasVendido control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;

    public VentanaListadoMasVendido() {
        initComponents();
        modeloTabla= new DefaultTableModel();
        tblIngrediente.setModel(modeloTabla);
        control = new ControladorListadoMasVendido(this);
        fila= new Vector<String>();

        fila.add("Ingredientes");
        fila.add("Porciones");
        modeloTabla.setColumnIdentifiers(fila);
        
    addAction();
    }

     public void addListener(ActionListener escuchador){
        btnSalir.addActionListener(escuchador);
        btnConsultar.addActionListener(escuchador);
        chcAsc.addActionListener(escuchador);
        chcDes.addActionListener(escuchador);
    }

    public void addAction(){
          btnConsultar.setActionCommand("Consultar");
        btnSalir.setActionCommand("Salir");
        chcAsc.setActionCommand("Asc");
        chcDes.setActionCommand("Des");;
    }


    public void agregar(String[] dato){
        fila = new Vector<String>();
        fila.add(dato[0]);
        fila.add(dato[1]);

        modeloTabla.addRow(fila);

        }

    public DefaultTableModel getModeloTabla() {
        return modeloTabla;
    }
   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        btnSalir = new javax.swing.JButton();
        chcDes = new javax.swing.JCheckBox();
        chcAsc = new javax.swing.JCheckBox();
        btnConsultar = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        tblIngrediente = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        btnSalir.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(270, 422, 100, 23);

        buttonGroup1.add(chcDes);
        chcDes.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        chcDes.setText("Descendente");
        getContentPane().add(chcDes);
        chcDes.setBounds(328, 26, 129, 20);
        chcDes.setBackground(new java.awt.Color(255,255,255));

        buttonGroup1.add(chcAsc);
        chcAsc.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        chcAsc.setText("Ascendente");
        getContentPane().add(chcAsc);
        chcAsc.setBounds(198, 26, 125, 20);
        chcAsc.setBackground(new java.awt.Color(255,255,255));

        btnConsultar.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnConsultar.setText("Consultar");
        getContentPane().add(btnConsultar);
        btnConsultar.setBounds(101, 422, 100, 23);

        tblIngrediente.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(tblIngrediente);

        getContentPane().add(jScrollPane3);
        jScrollPane3.setBounds(12, 46, 452, 364);
        jScrollPane3.setBackground(new java.awt.Color(255,255,255));

        jLabel2.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        jLabel2.setText("Orden del Listado");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(17, 26, 157, 20);

        jLabel4.setFont(new java.awt.Font("Ubuntu",1,15));
        jLabel4.setText("Ingrdientes mas Usados");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(156, 4, 187, 20);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 483, 486);
        this.setTitle("Lista de Ingredientes Mas Usados");
        getContentPane().setBackground(new java.awt.Color(255,255,255));
    }// </editor-fold>//GEN-END:initComponents

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaListadoMasVendido().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox chcAsc;
    private javax.swing.JCheckBox chcDes;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable tblIngrediente;
    // End of variables declaration//GEN-END:variables

}
